layui.use(['admin', 'HttpRequest', 'func', 'upload'], function () {

    var admin = layui.admin;
    var upload = layui.upload;
    var HttpRequest = layui.HttpRequest;

    //默认宽度
    const width = document.documentElement.clientWidth > 1000 ? document.documentElement.clientWidth / 2 : document.documentElement.clientWidth - 300;
    //默认高度
    const height = document.documentElement.clientHeight - 100;


    /**
     * 编辑用户
     */
    admin.events.editUser = function () {
        parent.layer.open({
            type: 2,
            maxmin: true,
            area: [width + 'px', height + 'px'],
            title: '编辑用户',
            content: Feng.ctxPath + '/view/shop/user/edit?id=' + Feng.getUrlParam("id")
        });

    }

    /**
     * 添加用户好友联系人
     */
    admin.events.addUserContacts = function () {
        parent.layer.open({
            type: 2,
            maxmin: true,
            area: [width + 'px', height + 'px'],
            title: '添加用户好友联系人',
            content: Feng.ctxPath + '/view/shop/userContacts/add?id=' + Feng.getUrlParam("id")
        });
    }

    /**
     * 查看账单图表
     */
    admin.events.selectPayBillsChart = function () {
        parent.layer.open({
            type: 2,
            maxmin: true,
            area: [width + 'px', height + 'px'],
            title: '查看账单图表',
            content: Feng.ctxPath + '/view/userPayBillsDetail/chart?id=' + Feng.getUrlParam("id")
        });
    }


    /**
     * 上传微信账单
     */
    upload.render({
        elem: '#uploadWxPayBillsBtn',
        url: Feng.ctxPath + '/userPayBillsDetail/upload/weixin',
        data: {"userId": Feng.getUrlParam("id")},
        accept: 'file',
        done: function (res) {
            Feng.success(res.message)
        },
        error: function () {
            Feng.error("上传文件失败！");
        }
    });


    /**
     * 上传支付宝账单
     */
    upload.render({
        elem: '#uploadAliPayBillsBtn',
        url: Feng.ctxPath + '/userPayBillsDetail/upload/alipay',
        data: {"userId": Feng.getUrlParam("id")},
        accept: 'file',
        done: function (res) {
            Feng.success(res.message)
        },
        error: function () {
            Feng.error("上传文件失败！");
        }
    });

});
